package com.bidepan.validation.three;

import com.bidepan.validation.four.CannotBlank;
import jakarta.validation.constraints.*;


public class User {
    @NotNull(message = "姓名不能为空")
    private String name;

    @Min(value = 0,message = "年龄不能小于0")
    @Max(value = 120,message = "年龄不能大于120")
    private int age;

    @Pattern(regexp="^1(3|4|5|7|8)\\d{9}$",message = "手机号格式有误！！")
    @NotBlank(message = "手机号不能为空！！")
    private String phone;

    //自定义注解(在four中定义)
    @CannotBlank
    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public @Pattern(regexp = "^1(3|4|5|7|8)\\d{9}$", message = "手机号格式有误！！") @NotBlank(message = "手机号不能为空！！")
    String getPhone() {
        return phone;
    }

    public void setPhone(@Pattern(regexp = "^1(3|4|5|7|8)\\d{9}$", message = "手机号格式有误！！") @NotBlank(message = "手机号不能为空！！")String phone) {
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", phone='" + phone + '\'' +
                ", message='" + message + '\'' +
                '}';
    }
}
